﻿using System.Configuration;

namespace AzureStorageMapper.Configurations
{
    public class ConfigurationUtils
    {
        public static CredentialElement GetTableStroageCredential()
        {
            AzureStorageMapperConfigurationSection section = GetSection();

            return section.TableStorage.Credential;
        }

        private static AzureStorageMapperConfigurationSection GetSection()
        {
            var section = ConfigurationManager.GetSection("AzureStorageMapperSettings") as AzureStorageMapperConfigurationSection;

            if (section == null)
            {
                throw new ConfigurationErrorsException("Missing AzureStorageMapperSettings ...");
            }

            return section;
        }
    }
}
